package com.aaa.service.fpa.impl;

import com.aaa.aspectFPA.InsertAnnFPA;
import com.aaa.aspectFPA.UpdateAnnFPA;
import com.aaa.dao.fpa.PersonalityDao;
import com.aaa.entity.PageSortEntity;
import com.aaa.entity.fpa.PersonalityEntity;
import com.aaa.service.fpa.PersonalityService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ：chenang（731712841@qq.com）
 * @date ：Created in 2022/8/30 11:40
 * @description：性格测试impl层 tbl_question_fpa
 * @modified By：
 * @version:
 */
@Service
public class PersonalityServiceImpl implements PersonalityService {
    @Autowired
    PersonalityDao personalityDao;
    // 分页排序,全部查询
    @Override
    public Page queryPersonalitAlla(PageSortEntity pageSortEntity, PersonalityEntity personalityEntity) {
        PageHelper.startPage(pageSortEntity.getPage(),pageSortEntity.getLimit(),pageSortEntity.getOrderString());
        List<PersonalityEntity> mapList = personalityDao.queryPersonalitAll(personalityEntity);
        Page page = (Page) mapList;
        System.out.println(page);
        return page;
    }
    // 添加
    @InsertAnnFPA
    @Override
    public int addPersonalit(PersonalityEntity personalityEntity) {

        return personalityDao.addPersonalit(personalityEntity );

    }
    // 多行删除
    @Override
    public int delPersonalit(int[] id) {
        ArrayList<Object> arrayList = new ArrayList<>();
        for (int i : id){
            arrayList.add(i);
        }
        int i = personalityDao.delPersonalit(arrayList);
        return i;
    }
    //  修改
    @UpdateAnnFPA
    @Override
    public int updatePersonalit(PersonalityEntity personalityEntity) {
        return personalityDao.updatePersonalit(personalityEntity);
    }
    // 去重校验
    @Override
    public int repetitionName(PersonalityEntity personalityEntity) {
        int i = personalityDao.repetitionName(personalityEntity);
        return i;
    }
}